#!/bin/bash
work_path=$(pwd)
commitlist_file=cxlcommit
output_file=cxllog
src_path_510=/home/y00447189/master/kernel/
src_path_419=/home/y00447189/1.0/kernel
cd $src_path_510
echo "workpath:$work_path, src_path:$src_path_510"
rm -rf $work_path/$output_file

while read rows
do
  #echo "$PWD"
  #echo "$rows"
  #commit_msg=$(echo $rows| cut -f 1 -d ' ')
  grep_info=$(git log --oneline | grep "$rows")
  if [ "x$grep_info" = "x" ]; then
     echo "cannot get commit id of $rows" >>  $work_path/$output_file
     continue
  fi

  #echo "$commit_msg"
  commit_id=$(echo $grep_info | cut -f -1 -d ' ')
  tag=$(git describe $commit_id)
  time_tmp=$(git show $commit_id | grep "Date: ")
  time=${time_tmp:8}

  cd $src_path_419
  grep_info=$(git log --oneline | grep "$rows")
  is_in_419="no"
  if [ "x$grep_info" = "x" ]; then
     #echo "cannot get commit id of $rows in 4.19"
     is_in_419="no"
  else
     # echo "get commit id of $rows in 4.19"
      is_in_419="yes"
  fi
  cd $src_path_510

   echo "$commit_id $tag $message $time $rows $is_in_419"
   echo "$commit_id $tag $message $time $rows $is_in_419"  >> $work_path/$output_file

done < $work_path/$commitlist_file